
/* RingBuffer_t.h */

#ifndef CT_RINGBUFFER_H
#define CT_RINGBUFFER_H

#include "ct_type.h"
/* Define the size of the ring buffer */
#ifndef RINGBUFFER_SIZE
#define RINGBUFFER_SIZE 255
#endif

/* Macro to ensure safe access to variables */
#define CC_ACCESS_NOW(type, variable) (*(volatile type *)&(variable))

/* Ring buffer structure */
typedef struct {
    uint8_t *buffer;
    uint16_t mask;
    volatile uint8_t put_ptr;
    volatile uint8_t get_ptr ;
} RingBuffer_t;

/* Function prototypes */
void ringbuf_init(RingBuffer_t *rb, int8_t *buffer, uint16_t size);
int8_t ringbuf_put(RingBuffer_t *rb, int8_t byte);
int8_t ringbuf_get(RingBuffer_t *rb, int8_t *byte);
int8_t ringbuf_full(const RingBuffer_t *rb);
int8_t ringbuf_empty(const RingBuffer_t *rb);
int8_t ringbuf_size(const RingBuffer_t *rb);
int8_t ringbuf_elements(const RingBuffer_t *rb);

#endif